home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac-Source 1994 July
/
Mac-Source_July_1994.iso
/
Other Langs
/
MacPerl ƒ
/
Perl Source ƒ
/
Perl
/
Distribute
< prev
next >
Wrap
Text File
|
1993-10-25
|
3KB
|
121 lines
Set DistFolder `Perl -Sx "{0}" "{1}" "{TempFolder}"Distribute.Dup` && ∂
"{TempFolder}"Distribute.Dup && ∂
Stuff -r "{DistFolder}" -o "{2}" && ∂
Delete -y "{DistFolder}" "{TempFolder}"Distribute.Dup
Exit
#!perl
#######################################################################
# Project : Distr -
# File : Distribute - Build a distribution
# Author : Matthias Neeracher
# Started : 29Jun93 Language : MPW Perl
# Modified : 31Jul93 MN Some unpleasant bugs
# Last : 31Jul93
#######################################################################
($distfile,$dup) = @ARGV;
open(DIST, $distfile) || die "$0: Could not open \"$distfile\"";
open(DUP, ">$dup") || die "$0: Could not open \"$dup\"";
print DUP "Echo #\n";
while (<DIST>) {
next if /^\s*$/;
next if /^\s*#/;
undef $atx,$aty;
if (/(.*)AT\s+(\d+)\s*,\s*(\d+)(.*)/) {
($atx,$aty,$_) = ($2, $3, $1 . $4);
}
if (/^\s*TARGET\s+\"([^"]+)\"\s*$/ || /^\s*TARGET\s+(\S+)\s*$/) {
$target = $1;
$target = ":$target" unless ($target =~ /^:/);
$target = "$target:" unless ($target =~ /:$/);
&mkdirs($target);
# print DUP "SetFile \'$target\' -l $atx,$aty\n" if (defined $atx);
} elsif ( /^\s*\"([^"]+)\"\s+AS\s+\"([^"]+)\"\s*$/
|| /^\s*\"([^"]+)\"\s+AS\s+(\S+)\s*$/
|| /^\s*(\S+)\s+AS\s+(\S+)\s*$/
) {
&linkfile($1, "$target$2", 0);
} elsif (/^\s*\"([^"]+)\"\s*$/ || /^\s*(\S+)\s*$/) {
&linkfiles($1, $target);
} else {
print STDERR "File \"$distfile\"; Line $. # Syntax Error\n";
}
}
$target =~ /^:?([^:]+)/;
print "\"$1\"\n";
sub mkdirs
{
local($dir) = @_;
if (!-d $dir) {
if ($dir =~ /(.*:)[^:]+:/) {
&mkdirs($1);
}
mkdir($dir, 0777) || die "Couldn't create directory \"$dir\"";
}
}
sub linkfile
{
local($from,$to,$linkem) = @_;
print STDERR "\t\t\t$from -> $to\n";
if ($to =~ /(.*):Icon∂n$/) {
print DUP "SetFile -a C \'$1\'\n";
}
$from =~ s/∂n/\n/g;
$to =~ s/∂n/\n/g;
unlink $to if (-e $to);
if ($linkem) {
symlink($from, $to) || die "Couldn't link \"$from\" to \"$to\"";
} else {
print DUP "Duplicate \'$from\' \'$to\'\n";
}
# print DUP "SetFile -noResolve \'$to\' -l $atx,$aty\n" if (defined $atx);
}
sub linkfiles
{
local($from,$target) = @_;
if ($from =~ /^(.*):([^:]+)$/) {
($fromdir,$fromfile) = ($1,$2);
} else {
($fromdir,$fromfile) = (":",$from);
}
if ($fromfile =~ /[≈?]/) {
$fromfile =~ s/\./\\./;
$fromfile =~ s/≈/.*/;
$fromfile =~ s/\?/./;
opendir(FROMDIR, $fromdir) || "Could not open \"$fromdir\"";
while ($from = readdir(FROMDIR)) {
next unless $from =~ /^$fromfile$/;
&linkfile("$fromdir:$from", "$target$from", 1);
}
} else {
&linkfile($from,"$target$fromfile", 1);
}
}